package com.byxm.wlgw.control.admin;

import java.util.List;

import com.byxm.wlgw.bean.DdspxxBean;
import com.byxm.wlgw.bean.DdxxBean;
import com.byxm.wlgw.common.Pages;
import com.byxm.wlgw.control.BaseAction;
import com.byxm.wlgw.service.DdspxxService;
import com.byxm.wlgw.service.DdxxService;

public class Ddxx_glAction extends BaseAction {
	private static final long serialVersionUID = 1L;

	private DdxxBean ddxxBean;
	
	private List<DdxxBean> lstDdxx;
	
	private Pages page;
	
	private String pageNumSet="20";
	
	/*****************订单详细信息***********/
	private List<DdspxxBean> lstDdspxx;
	
	/*********sevice*******/
	DdxxService ddxxService=new DdxxService();
	DdspxxService ddspxxService=new DdspxxService();
	private String ddxxid="";
	/**
	 * 查看所有订单信息
	 * @return
	 */
	public String list(){
		int iCnt=0;
		if(ddxxBean==null){
			ddxxBean = new DdxxBean();
			ddxxBean.setJyzt(2);
		}
		iCnt=ddxxService.findDdxxCnt(ddxxBean);
		if(page==null){
			page=new Pages();
		}
		this.setMyPage(iCnt, Integer.parseInt(pageNumSet));//设置page
		try {
			lstDdxx=ddxxService.findListDdxx(ddxxBean, page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success_01";
	}
	/***
	 * 加载订单信息
	 */
	public String load(){
		ddxxBean=ddxxService.findDdxxBean(ddxxid.trim());
		try {
			lstDdspxx=ddspxxService.findDdspxx(ddxxid.trim());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success_02";
	}
	
	public String update(){
		try {
			ddxxService.updateDdxxJyzt(ddxxBean);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success_03";
	}
	
	
	
/******************私有方法************************/
	/**
	 * 设置page
	 */
	@SuppressWarnings("unused")
	private void setMyPage(int iCnt,int PageNumSet2){
		page.setPageNum(PageNumSet2);
		page.setPageNumFin(PageNumSet2);
		page.setJlzts(iCnt);
		if(iCnt<PageNumSet2){
			page.setZys(1);//如果总条数小于每页总条数  总页数等于1
			page.setPageNum(iCnt);//设置每页显示多少
		}else if(iCnt%PageNumSet2!=0){
			page.setZys((iCnt/PageNumSet2)+1);
			if(page.getCpage()!=(iCnt/PageNumSet2)+1){
				page.setPageNum(PageNumSet2);
			}
			if(page.getCpage()==(iCnt/PageNumSet2)+1){
				page.setPageNum(iCnt%PageNumSet2);
			}
		}else if(iCnt%PageNumSet2==0){
			page.setZys(iCnt/PageNumSet2);
		}
	}
	
	
	
	
	
	
	/***************setter getter**************/

	public DdxxBean getDdxxBean() {
		return ddxxBean;
	}
	public void setDdxxBean(DdxxBean ddxxBean) {
		this.ddxxBean = ddxxBean;
	}
	public List<DdxxBean> getLstDdxx() {
		return lstDdxx;
	}
	public void setLstDdxx(List<DdxxBean> lstDdxx) {
		this.lstDdxx = lstDdxx;
	}
	public Pages getPage() {
		return page;
	}
	public void setPage(Pages page) {
		this.page = page;
	}
	public String getPageNumSet() {
		return pageNumSet;
	}
	public void setPageNumSet(String pageNumSet) {
		this.pageNumSet = pageNumSet;
	}
	public String getDdxxid() {
		return ddxxid;
	}
	public void setDdxxid(String ddxxid) {
		this.ddxxid = ddxxid;
	}
	public List<DdspxxBean> getLstDdspxx() {
		return lstDdspxx;
	}
	public void setLstDdspxx(List<DdspxxBean> lstDdspxx) {
		this.lstDdspxx = lstDdspxx;
	}
	
}
